package com.sudoku.screen;

import java.util.ArrayList;

import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.sudoku.utility.Constants;
import com.sudoku.utility.Locator;

public class BlackScreen implements Screen, Constants {

	private float time;
	private boolean render;
	private Screen next;

	public BlackScreen(Screen next) {
		this.next = next;
		time = 0;
		render = true;
	}

	@Override
	public void render(float delta) {
		ShapeRenderer sh = new ShapeRenderer();
		sh.setTransformMatrix(Locator.getCamera().view);
		sh.setProjectionMatrix(Locator.getCamera().projection);
		sh.begin(ShapeType.Filled);
		sh.setColor(0, 0, 0, 1);
		sh.rect(0, 0, ACTUAL_VIRTUAL_WIDTH, ACTUAL_VIRTUAL_HEIGHT);
		sh.end();
		time += delta;
		if (time > 0.5f && render) {
			ArrayList<TransitionEffect> effects = new ArrayList<TransitionEffect>();
			effects.add(new FadeInTransitionEffect(0.5f));

			Screen transitionScreen = new TransitionScreen(Locator.getGame(), this, next, effects);
			Locator.getGame().setScreen(transitionScreen);
			render = false;
		}
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub

	}

	@Override
	public void show() {
		// TODO Auto-generated method stub

	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

}
